#!/usr/bin/perl

use Net::Twitter;
use Scalar::Util 'blessed';

#Aquí van mis keys

my $nt = Net::Twitter->new(
    traits   => [qw/OAuth API::REST/],
    consumer_key        => $consumer_key,
    consumer_secret     => $consumer_secret,
    access_token        => $token,
    access_token_secret => $token_secret,
);

my $result = $nt->update('Esto es un twit para AAP. @Alberce no hace esto ñañañaña :DDDDD');
print "... Has actualizado tu estado :)\n\n";

eval {
    my $statuses = $nt->friends_timeline();
    print "Últimos 20 tweets publicados:\n";
    print "-----------------------------\n";
    for my $status ( @$statuses ) {
        print $status->{user}{screen_name}." publicó '".$status->{text}."' el ".$status->{created_at}."\n\n";
    }
};
if ( my $err = $@ ) {
    die $@ unless blessed $err && $err->isa('Net::Twitter::Error');
    warn "HTTP Response Code: ", $err->code, "\n",
         "HTTP Message......: ", $err->message, "\n",
         "Twitter error.....: ", $err->error, "\n";
}
